<?php
require_once("../inc/conn.php");
require_once("../inc/session.php");

//查询开始
if(!empty($_POST["dt1"])){
		$dt1=$_POST["dt1"]; 
}else{
		$dt1="";
}

if(!empty($_POST["dt2"])){
		$dt2=$_POST["dt2"]; 
}else{
		$dt2="";
}


if($dt1=="" || $dt2==""){
    $sql = "select * from shareinfo order by id desc"; 
}else{
	  $sql = "sselect * from shareinfo where dt>='".$dt1."' and dt<='".$dt2."'  order by id desc"; 
}

$rs=$conn->query($sql);
$zongtiaoshu=$rs->num_rows;

//echo $zongtiaoshu;

?>
<!doctype html>
<html>
<meta charset="utf-8" />
<title>显示数据记录</title>
</head>

<body>

<form><table width="98%" border="1" align="center" cellpadding="5">
  <tbody>
    <tr>
      <td colspan="4" align="center">统计报表</td>
    </tr>
    <tr>
      <td colspan="2" align="left">总条数：<?php echo $zongtiaoshu;?></td>
      <td colspan="2" align="right">开始时间：
        <input type="date" name="dt1" id="datetime"> 
        - 
        结束时间
        <input type="date" name="dt2" id="datetime2">
        &nbsp; <input type="submit" name="submit" id="submit" value="按时间查询" formmethod="post" formaction=""></td>
      </tr>
    <tr>
      <td width="8%" align="center">序号</td>
      <td width="20%" align="center">所属部门</td>
      <td width="27%" align="center">姓名</td>
      <td width="20%" align="center">数量</td>
      </tr>
	  
	<?php
	  $i=0;
while ($row = $rs->fetch_assoc()) {
	$i++;
?> 
    <tr>
      <td align="center"><?php echo $i;?></td>
      <td align="center">
		  
		  <?php 
	      $dsql="select * from department where id=".$row[ "sortid" ];
	      $drs=$conn->query($dsql);
	      $drow=$drs->fetch_assoc();
		  echo $drow["name"];
		  ?>
		
		
		</td>
      <td align="center"><?php echo $row[ "name" ];?></td>
      <td align="center"><?php echo $row[ "num" ];?></td>
      </tr>
	  
<?php
	}
?> 
    </tbody>
</table></form>
</body>
</html>
